﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Silvery.Scene;
using System.Windows.Resources;
using System.IO;
using System.Windows.Markup;

namespace Sample03_Scene
{
    //这是一个纯粹的xaml模式地图格式
    public class Sample_2 : NScene
    {
        public Sample_2()
        {
            this.SceneEnter(LoadXAMLAndGetShape(new Uri("/Sample03_Scene;component/Scene01.xaml", UriKind.Relative)));
            this.MouseLeftButtonDown += new MouseButtonEventHandler(Test_1_MouseLeftButtonDown);
            this.Children.Add(new TextBlock() { Text = "点击一下鼠标试试", FontSize = 64 });
        }
        void Test_1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            LookAtPoint(e.GetPosition(this));
        }
        FrameworkElement LoadXAMLAndGetShape(Uri url)
        {
            string xaml = string.Empty;
            StreamResourceInfo sri = Application.GetResourceStream(url);
            using (StreamReader sr = new StreamReader(sri.Stream))
            {
                xaml = sr.ReadToEnd();
            }
            return (FrameworkElement)XamlReader.Load(xaml);
        }
    }
}
